local pingjian = fk.CreateSkill{
    name = "SP_heg__pingjian",
}

Fk:loadTranslationTable{
    ["SP_heg__pingjian"] = "评鉴",
    [":SP_heg__pingjian"] = "准备阶段，你可以随机获得其他角色的武将牌上的一个无类型标签技能直到你的下回合开始。"..
    "<font color='blue'><br />◆类型标签：锁定技、限定技、主将技、副将技、阵法技和君主技。",
    ["@heg__pingjian"] = "评鉴",

    ["$SP_heg__pingjian1"] = "千帆过尽，评枭雄之谋，论天下分合!",
    ["$SP_heg__pingjian2"] = "三尺毛峰，引九天之水，濯一世功名!",
}

pingjian:addEffect(fk.EventPhaseStart,{
        anim_type = "offensive",
        can_trigger = function(self, event, target, player, data)
           return target == player and player:hasSkill(pingjian.name) and player.phase == Player.Start
        end,
        on_use = function(self, event, target, player, data)
          local room = player.room
          local skill_names = {} --用来装全场技能
          local targets = table.filter(room:getOtherPlayers(player), function(p) return p.kingdom ~= "unknown" end)
          room:sortByAction(targets)
          for _, p in ipairs(targets) do
          for _, skill_name in ipairs(Fk.generals[p.general]:getSkillNameList()) do
            local skill = Fk.skill_skels[skill_name]
            if skill and #skill.tags == 0 and skill.name ~= "hs__heyi" and skill.name ~= "tianfu" and skill.name ~= "ld__niaoxiang" and skill.name ~= "fengshi" and skill.name ~= "ld__fangyuan"
            and skill.name ~= "ld__fengyang" and not p:isFakeSkill(Fk.skills[skill_name])
            then --排除阵法技
            table.insert(skill_names, skill_name)
              end
            end
            if p.deputyGeneral ~= "anjiang" then
              for _, skill_name in ipairs(Fk.generals[p.deputyGeneral]:getSkillNameList()) do
                local skill = Fk.skill_skels[skill_name]
                if skill and #skill.tags == 0 and skill.name ~= "hs__heyi" and skill.name ~= "tianfu" and skill.name ~= "ld__niaoxiang" and skill.name ~= "fengshi" and skill.name ~= "ld__fangyuan"
                and skill.name ~= "ld__fengyang" and not p:isFakeSkill(Fk.skills[skill_name])
                then --副将
                table.insert(skill_names, skill_name)
                end
              end
            end
          end
          if #skill_names == 0 then return false end
            -- 随机选择一个技能
            local random_skill_name = table.random(skill_names)
               -- 为当前玩家添加随机选择的技能
            room:handleAddLoseSkills(player, random_skill_name, nil, true, false)
            room:setPlayerMark(player, "@heg__pingjian", random_skill_name)
            room:setPlayerMark(player, "heg__pingjian_used", 1)
        end,
})

pingjian:addEffect(fk.TurnStart,{
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return target == player and player:getMark("heg__pingjian_used") > 0
      end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player, "heg__pingjian_used", 0)
        if player:getMark("@heg__pingjian") ~= 0 then
            local skill = player:getMark("@heg__pingjian")
            room:setPlayerMark(player, "@heg__pingjian", 0)
            room:handleAddLoseSkills(player, "-"..skill, nil, true, false)
        end
      end,
})

pingjian:addEffect(fk.BuryVictim,{
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return target == player and player:getMark("heg__pingjian_used") > 0
      end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player, "heg__pingjian_used", 0)
        if player:getMark("@heg__pingjian") ~= 0 then
            local skill = player:getMark("@heg__pingjian")
            room:setPlayerMark(player, "@heg__pingjian", 0)
            room:handleAddLoseSkills(player, "-"..skill, nil, true, false)
        end
      end,
})

return pingjian